package com.fanketly.musicdiary.ui.components

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.fanketly.musicdiary.ui.theme.SmallDimen

@Composable
fun <T> CommonList(
    bottomAppBarHeight: Dp = 0.dp,
    list: List<T>,
    key: ((item: T) -> Any)? = null,
    itemContent: @Composable LazyItemScope.(item: T) -> Unit,
) {
    val listState = rememberLazyListState()
    LazyColumn(
        modifier = Modifier
            .padding(bottom = bottomAppBarHeight)
            .fillMaxSize(),
        state = listState,
        verticalArrangement = Arrangement.spacedBy(SmallDimen)
    ) {
        items(list, key = key, itemContent = itemContent)
    }
}
